home *** CD-ROM | disk | FTP | other *** search
- '----------------------------------------------------------------------
- 'FUNCTION INITIALS
- 'Visual Basic function
- 'Purpose: changes a name to intials
- 'Examples: initials(Joseph E. Blow) results in JEB
- ' initials(Joseph Blow) results in JB
- 'Released to the public domain, no warranties, use at your own risk.
- 'Stephen E. Covell, CompuServe 75010,3700
- ' If you have a better way to do this, or any
- ' improvements, please let me know. You may want
- ' to declare: function initials (mNameInit as String)
- ' or: function initials (mNameInit as String) as String
- ' in your application.
- '----------------------------------------------------------------------
-
- Function Initials (mNameInit)
-
- '---Get leftmost letter of string
- mLeft = UCase(Left(mNameInit, 1))
-
- '---Get place number value of character after space,
- '---this will be either the middle intitial or the last name
- Dim mMiddleNumber As Integer
- mMiddleNumber = InStr(mNameInit, " ") + 1
-
- '---Get character at that place number value
- mMiddle = UCase(Mid(mNameInit, mMiddleNumber, 1))
-
- '---Get place number value of character 2 spaces past period
- '---this should be the last name if a middle initial was entered
- If InStr(mNameInit, ".") Then 'See if there is a period in the string
- Dim mLastNumber As Integer
- mLastNumber = InStr(mNameInit, ".") + 2
- mLast = UCase(Mid(mNameInit, mLastNumber, 1))
- Else
- mLast = "" 'No period, no middle initial, so make it blank
- End If
- Initials = mLeft & mMiddle & mLast
-
- End Function
-